<template>
  <el-dropdown @command="mycommand">
    <span class="el-dropdown-link">
      <i class="el-icon-eleme"></i>
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale === 'zh'" command="zh">
        中文
      </el-dropdown-item>
      <el-dropdown-item :disabled="$i18n.locale === 'en'" command="en">
        English
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  name: 'lang',
  methods: {
    mycommand (command) {
      if (command === 'zh') {
        Cookie.set('lang', 'zh')
      } else {
        Cookie.set('lang', 'en')
      }
      // 刷新页面
      this.$router.go(0)
    }
  }
}
</script>

<style></style>
